#include "Mesh.hpp"

Mesh::Mesh(const std::vector<Vertex> vertices, const std::vector<uint32_t> indices)
{
    indices_size = indices.size();
    setup(vertices, indices);
}
void Mesh::setup(std::vector<Vertex> vertices, std::vector<uint32_t> indices)
{
    glGenVertexArrays(1, &vao);
    glBindVertexArray(vao);

    vbo.bind_copy(vertices);
    ibo.bind_copy(indices);

    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), static_cast<void*>(0));
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, Normal)));
    glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, TexCoord)));

    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);
    glEnableVertexAttribArray(2);
}
Mesh::~Mesh() {}